from cart import models
from rest_framework import serializers


class CartSerializer(serializers.ModelSerializer):
    user1 = serializers.SerializerMethodField(read_only=True)
    course1 = serializers.SerializerMethodField(read_only=True)

    class Meta:
        model = models.Cart
        fields = '__all__'
        # depth = 1



    def get_user1(self, obj):
        return {'username':obj.user.name}

    def get_course1(self, obj):
        return {'name': obj.course.name, 'price' : obj.course.price, 'img' : obj.course.img,'level': obj.course.level.name}

